From e99ac8f6d831a3fccaffd255bf229a5efe633870 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Tue, 28 Sep 2021 16:59:22 -0400 Subject: [PATCH] builder: Simplify parameter collection This avoids setting the GValue only to toss it at the end of the loop body. Instead, we can just do nothing if this property isn't interesting to us. --- gtk/gtkbuilder.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/gtk/gtkbuilder.c b/gtk/gtkbuilder.c index fef468e8bb..ed90fd7b99 100644 --- a/gtk/gtkbuilder.c +++ b/gtk/gtkbuilder.c @@ -539,10 +539,19 @@ gtk_builder_get_parameters (GtkBuilder *builder, PropertyInfo *prop = g_ptr_array_index (properties, i); const char *property_name = prop->pspec->name; GValue property_value = G_VALUE_INIT; + ObjectProperties *params; if (prop->applied) continue; + if ((prop->pspec->flags & filter_flags) != 0) + params = filtered_parameters; + else + params = parameters; + + if (!params) + continue; + if (prop->value) { g_value_init (&property_value, G_PARAM_SPEC_VALUE_TYPE (prop->pspec)); @@ -616,19 +625,8 @@ gtk_builder_get_parameters (GtkBuilder *builder, * copy it to one of the two arrays, or unset it. */ g_assert (G_IS_VALUE (&property_value)); - - if ((prop->pspec->flags & filter_flags) != 0 && filtered_parameters) - { - object_properties_add (filtered_parameters, property_name, &property_value); - prop->applied = TRUE; - } - else if ((prop->pspec->flags & filter_flags) == 0 && parameters) - { - object_properties_add (parameters, property_name, &property_value); - prop->applied = TRUE; - } - else - g_value_unset (&property_value); + object_properties_add (params, property_name, &property_value); + prop->applied = TRUE; } } -- 2.30.2